<?php

/**
 * Group models
 *
 * Group models in bundles
 *
 * PHP Version: 1.2.3
 *
 * @author Johari <joharijumali@gmail.com>
 */

namespace Admin\Models\Modul;

use \Laravel\Database\Eloquent\Model as Eloquent;
use Datagrid;
use Laravel\Config;

/**
 * Data Group Model Class
 *
 * Create model class for lookup data
 *
 * @author Johari <joharijumali@gmail.com>
 */

class Flow extends Eloquent
{

    public static $timestamps = true;
    public static $table = 'sys_flow';
    public static $key = 'sf_id';

	/**
     * Function steps
	 *
	 * @return steps.
     */
	public function steps()
	{
        return $this->has_many('Admin\Models\Modul\Step', 'sf_id');
	}

	/**
     * Function listFlow
	 *
	 * @return listFlow.
     */
    public static function listFlow()
	{
        $allFlow = Flow::paginate(Config::get('system.pagination'));
        $datagrid = new Datagrid;
        $datagrid->setFields(array('sf_name' => 'Flow'));
        $datagrid->setAction('edit', 'editFlowModal', true, array(static::$key));
        // $datagrid->setAction('delete','deleteRole',true,array('userid'));
        $datagrid->setAction('step', 'step');
        $datagrid->setAction('rule', 'rule');
        $datagrid->setTable('flows', 'table table-bordered table-hover table-striped table-condensed');
        $datagrid->build($allFlow, static::$key);

        return $datagrid->render();
    }

}

?>